package com.example.demo.controller;

import com.example.demo.strategy.context.UploadStrategyContext;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * The type File controller.
 * 操作文件的Controller
 */
@RestController
@RequestMapping("file")
@RequiredArgsConstructor
public class FileController {

    private final UploadStrategyContext context;


    /**
     * Upload picture string.
     * 文件上传
     *
     * @param file the file
     * @return the string
     */
    @PostMapping
    public String uploadPicture(MultipartFile file) {
        return context.executeUploadStrategy("demo/", file);
    }
}
